package LeetCode刷题;

/**
 * @program: Java_Study
 * @author: Xiaofan
 * @createTime: 2021-11-15 16:25
 * @description: Functions of this class is
 * class Solution {
 *     public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
 *         TreeNode ancestor = root;//关键是要看到当前的树为**二叉搜索树**
 *         while (true) {//所以一直找，如果当前p q的值都比当前祖先小的话，则往祖先的左子树去找，否则去祖先的右子树去找，否则就返回
 *             if (p.val < ancestor.val && q.val < ancestor.val) {
 *                 ancestor = ancestor.left;
 *             } else if (p.val > ancestor.val && q.val > ancestor.val) {
 *                 ancestor = ancestor.right;
 *             } else {
 *                 break;
 *             }
 *         }
 *         return ancestor;
 *     }
 **/
public class 二叉搜索树的最近公共节点 {
}